package com.example.administrator.liveapp.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.administrator.liveapp.ApplicationUtils;
import com.example.administrator.liveapp.MainActivity;
import com.example.administrator.liveapp.R;
import com.example.administrator.liveapp.Xutils3.MyCallBack;
import com.example.administrator.liveapp.Xutils3.XUtils;
import com.example.administrator.liveapp.bean.AdvertisingBean;
import com.example.administrator.liveapp.utils.AppUrl;
import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Arrays;

import cn.bingoogolapple.bgabanner.BGABanner;

/**
 * 引导页activity
 */

public class WelcomePage extends AppCompatActivity {

    private static final String TAG = WelcomePage.class.getSimpleName();
    private BGABanner mBackgroundBanner;
    AdvertisingBean bean;
//    private BGABanner mForegroundBanner;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ApplicationUtils applicationUtils = new ApplicationUtils();
        applicationUtils.addActivity(this);
        initView();
        setListener();
        processLogic();
    }
    private void initView() {
        //去掉Activity上面的状态栏
        getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN);
        setContentView(R.layout.activity_welcome_page);
        mBackgroundBanner = (BGABanner) findViewById(R.id.banner_guide_background);
//        mForegroundBanner = (BGABanner) findViewById(R.id.banner_guide_foreground);//给引导页每张图片添加文字背景说明
    }

    private void setListener() {
        /**
         * 设置进入按钮和跳过按钮控件资源 id 及其点击事件
         * 如果进入按钮和跳过按钮有一个不存在的话就传 0
         * 在 BGABanner 里已经帮开发者处理了防止重复点击事件
         * 在 BGABanner 里已经帮开发者处理了「跳过按钮」和「进入按钮」的显示与隐藏
         */
        mBackgroundBanner.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
            @Override
            public void onClickEnterOrSkip() {
                startActivity(new Intent(WelcomePage.this, MainActivity.class));
                overridePendingTransition(R.anim.zoomin,R.anim.zoomout);
                finish();
            }
        });
    }

    private void processLogic() {
        // 设置数据源

        mBackgroundBanner.setData(R.drawable.guidepage01, R.drawable.guidepage02, R.drawable.guidepage03,R.drawable.guidepage04);

//        mForegroundBanner.setData(R.drawable.uoko_guide_foreground_1, R.drawable.uoko_guide_foreground_2, R.drawable.uoko_guide_foreground_3);//设置文字背景的数据源
    }

    @Override
    protected void onResume() {
        super.onResume();

        // 如果开发者的引导页主题是透明的，需要在界面可见时给背景 Banner 设置一个白色背景，避免滑动过程中两个 Banner 都设置透明度后能看到 Launcher
        mBackgroundBanner.setBackgroundResource(android.R.color.white);
    }

}
